package com.alexgaoyh.MutiModule.Dubbo.RWSeperate.provider.read.mutiDatabase;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.MutiModule.common.myPage.MyPageView;
import com.MutiModule.common.myPage.util.MyPageViewUtilss;
import com.MutiModule.common.vo.mybatis.pagination.Page;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.api.mutiDatabase.read.IMutiDatabaseReadService;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.mutiDatabase.MutiDatabase;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.mutiDatabase.MutiDatabaseExample;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.mutiDatabase.MutiDatabaseMapper;

@Service(value = "mutiDatabaseService")
public class MutiDatabaseServiceImpl implements IMutiDatabaseReadService{
	
	@Resource(name = "mutiDatabaseMapper")
	private MutiDatabaseMapper mapper;

	@Override
	public int countByExample(MutiDatabaseExample example) {
		return mapper.countByExample(example);
	}

	@Override
	public List<MutiDatabase> selectByExample(MutiDatabaseExample example) {
		return mapper.selectByExample(example);
	}

	@Override
	public MutiDatabase selectByPrimaryKey(Long id) {
		return mapper.selectByPrimaryKey(id);
	}

	@Override
	public MyPageView<MutiDatabase> generateMyPageViewVO(MutiDatabaseExample exampleWithOutPage, Page page) {
		
		int _totalCount = mapper.countByExample(exampleWithOutPage);
		
		exampleWithOutPage.setPage(page);
		
		List<MutiDatabase> _list = mapper.selectByExample(exampleWithOutPage);
		
		MyPageView<MutiDatabase> pageView = new MyPageViewUtilss<MutiDatabase>().generaterMyPageView(page.getLength(), page.getPageNo(), _totalCount, _list);
		
		return pageView;
	}

}
